package com.spring.application;

import com.java.bean.Person;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ApplicationObjectSupport;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringIOCConfApp {

    @Test
    public void getBean(){
        ApplicationContext context = new ClassPathXmlApplicationContext("springIOC-conf.xml");
        Person person = context.getBean("person", Person.class);
        System.out.println(person);
    }

    @Test
    public void getBeanById(){
        ApplicationContext context = new ClassPathXmlApplicationContext("springIOC-conf.xml");
        Object person = context.getBean("person");
        System.out.println(person);
    }

    @Test
    public void getBeanByClass(){
        ApplicationContext context = new ClassPathXmlApplicationContext("springIOC-conf.xml");
        Person person = context.getBean(Person.class);
        System.out.println(person);
    }

    @Test
    public void getBeanByConstrouct(){
        ApplicationContext context = new ClassPathXmlApplicationContext("springIOC-conf.xml");
        Object person = context.getBean("person02",Person.class);
        System.out.println(person);
    }

    @Test
    public void getBeanByP(){
        ApplicationContext context = new ClassPathXmlApplicationContext("springIOC-conf.xml");
        Object person = context.getBean("person03",Person.class);
        System.out.println(person);
    }
}
